/*****************************************************************************
*   Copyright (c) 2019 Thermo Fisher Scientific. All rights reserved.        *
*****************************************************************************/
/** @file
    @section DESCRIPTION
    Header file of modbus common file

    @author  LiuMing (ming.liu2@thermofisher.com)

    @version 1.0 

    @section LICENSE
    Use of the software source code and warranty disclaimers are
    identified in the Software Agreement associated herewith.

    @section GIT_PATH
    git@cnshf-cic-sw-bitbucket.apac.thermo.com:7999/vert/mcu.git
	
	@section USAGE

*/

#ifndef _MB_COMMON_H
#define _MB_COMMON_H




typedef enum 
{
  FALSE = 0,
  TRUE = 1
} bool;
	

/* Modbus function code */
#define READ_HOLDING_REGS_FUNCT_CODE            0x03
#define READ_INPUT_REGS_FUNCT_CODE              0x04
#define WRITE_SINGLE_REG_FUNCT_CODE             0x06
#define WRITE_MULTIPLE_REGS_FUNCT_CODE          0x10
#define READ_WRITE_MULTIPLE_REGS_FUNCT_CODE     0x17

#define READ_HOLDING_REGS_FUNCT_CODE_ERR        0x83
#define READ_INPUT_REGS_FUNCT_CODE_ERR          0x84
#define WRITE_SINGLE_REG_FUNCT_CODE_ERR         0x86
#define WRITE_MULTIPLE_REGS_FUNCT_CODE_ERR      0x90
#define READ_WRITE_MULTIPLE_REGS_FUNCT_CODE_ERR 0x97



#define MB_EXTERNAL_U16_LENGTH 	28
#define MB_EXTERNAL_F32_LENGTH 	16





unsigned short          modbus_crc16(unsigned char *crcBuf, int nSize);







#endif

